import React from 'react'
import './index.scss'
import { connect } from 'react-redux'
import * as counterActions from '../../store/actions/counter'
import * as baseInfoActions from '../../store/actions/baseInfo'
import {bindActionCreators} from 'redux'

import LeftCon from './leftCon'
import MidCon from './midCon'
import RightCon from './rightCon'

class HomeAdmin extends React.Component {
  handleClick=()=> {
    console.log(this.props.baseInfo)
  }
  UNSAFE_componentWillMount() {
    this.props.baseInfoActions.getBaseInfoFn()
  }
  render() {
    let {baseInfoList} = this.props.baseInfo
    console.log(this.props.baseInfo)
    return (
      <div className="home-container">
        {baseInfoList ? baseInfoList.map((item)=> {
          return (
            <div key={item.id}>{item.status}</div>
          )
        }): ''}
        <div className="left-container">
          <LeftCon></LeftCon>
        </div>
        <div className="mid-container">
          <MidCon></MidCon>
        </div>
        <div className="right-container">
          <RightCon></RightCon>
        </div>
      </div>
    )
  }
}

const mapStateToProps = (state)=> {
  return {
    counter: state.counter,
    baseInfo: state.baseInfo
  }
}
const mapDisPatchToProps = (dispatch)=> {
  return {
    counterActions: bindActionCreators(counterActions, dispatch),
    baseInfoActions: bindActionCreators(baseInfoActions, dispatch),
  }
}

export default connect(mapStateToProps, mapDisPatchToProps)(HomeAdmin) 